package banking;

public class Account {
    //成员属性
    private double balance;//余额

    // 无参构造
    public Account() {

    }

    // 有参构造
    public Account(double balance) {
        this.balance = balance;
    }

    // set  get
    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    //成员方法--存款
    public double deposit(double amt) {
        if (amt < 0) {
            System.out.println("您的存款金额不能小于0");
        }
        return balance += amt;
    }

    //成员方法--取款
    public double withdraw(double amt) {

        if (amt < 0) {
            System.out.println("您的取款金额不能小于0");
        }
        if (amt > balance) {
            System.out.println("您的取款金额不能大于您的存款金额");
        }
        return balance -= amt;
    }


    public boolean withdraw1(double amt) {
        if (amt > 0 && amt < balance == true) {
            balance -= amt;
            System.out.print("Withdraw " + amt + " : ");
            return true;
        } else {
            System.out.print("Withdraw " + amt + " : ");
            return false;
        }
    }

    public boolean deposit1(double amt) {
        if (amt < 0) {
            System.out.print("Deposit " + amt + " : ");
            return false;
        } else {
            balance += amt;
            System.out.print("Deposit " + amt + " : ");
            return true;
        }
    }


}

